<template>
	<view class="note">
		<view class="note-header">
			<view class="note-header_tabs u-flex">
				<view class="search-btn" @click="$goPage('/staff/imSearch')" v-if="false">
					<u-icon name="search" color="#9F9F9F" size="44"></u-icon>
				</view>
				<u-tabs :list="list1" @change="tabChange" :current="current" inactive-color="#8D8D8D"
					class="tab-content" bar-width="150" item-width="220" bar-height="8" font-size="32"></u-tabs>
				<view class="note-add_btn" @click="$goPage('/staff/search')" v-if="vuex_user.type == 1">
					<i class="icon icon-add-friend"></i>
				</view>
			</view>
		</view>
		<view class="note-tab container-conversation" v-show="current == 0">
			<view class="note-section">
				<view class="note-item u-flex" @click="$goPage('/note/inform', {type:2, unreadTotal: unreadTotal})">
					<view class="note-item_avatar">
						<u-image width="72rpx" height="72rpx" border-radius="16rpx" src="/static/images/system.png">
						</u-image>
						<u-badge type="error" :count="msgCount" :offset="[-8,-8]" size="mini"></u-badge>
					</view>
					<view class="note-item_content u-flex-1">
						<view class="note-item_content--name">{{$t('chat.btn_notify')}}</view>
					</view>
				</view>
			</view>
			<scroll-view class="conversations" scroll-y="true" @click="closeTip">
				<view v-if="JSON.parse(JSON.stringify(conversations)).length > 0" style="position:relative">
					<view class="tooltips" :class="isShowTip ? 'tooltips-active': 'tooltips-inactive'"
						:style="{'top': top + 'rpx'}">
						<view class="tooltips-item" @click="topConversation()" @longpress="currentTip = 0"
							:class="currentTip == 0 ? 'current-tip' : ''">
							{{actionPopup.conversation ? (actionPopup.conversation.is_top == 1 ? $t('chat.chat_unpin') : $t('chat.chat_top')): $t('chat.chat_top')}}
						</view>
						<view class="tooltips-item" @click="deleteConversation()" @longpress="currentTip = 1" 
							:class="currentTip == 1 ? 'current-tip' : ''">{{$t('chat.chat_delete_chat')}}</view>
					</view>
					<view class="scroll-item"
						:class="currentConversation == key || conversation.is_top == 1 ? 'current-item': ''"
						v-for="(conversation, key) in conversations" :key="key" @longpress="longPress(conversation,key)"
						@click="closeTip"  @touchmove="handletouchmove">
						<view class="item-head">
							<image :src="conversation.conversation_avatar || '../../static/images/avatar.jpg'"
								class="head-icon"></image>
							<u-badge type="error" :count="conversation.unread" :offset="[-12,12]"
								style="width:36rpx;height:36rpx"></u-badge>
						</view>
						<view class="scroll-item_info" @click="navigateToChat(conversation)">
							<view class="item-info-top">
								<text class="item-info-top_name">{{conversation.conversation_name}}</text>
								<view class="item-info-top_time">{{formatDate(conversation.last_message_timestamp)}}
								</view>
							</view>
							<view class="item-info-bottom">
								<view class="item-info-bottom-item">
									<view class="item-info-top_content" v-if="!conversation.last_message_recalled">
										<text
											class="unread-text">{{conversation.last_message_read === false && conversation.last_message_sender_id == vuex_user.uid?'['+ $t('chat.message_unread') +']':''}}</text>

										<text
											v-if="conversation.conversation_type === 'private'">{{conversation.last_message_sender_id == vuex_user.uid? $t('chat.chat_me'): conversation.conversation_name}}:</text>
										<text
											v-else>{{conversation.last_message_sender_id == vuex_user.uid? $t('chat.chat_me'): lastMessageSenderName(conversation.last_message_sender_name)}}:</text>
										<text v-if="conversation.isAtAll && conversation.conversation_type === 'group'">
											<label
												class="red-text">[{{$t('chat.chat_group_notice')}}]</label>{{conversation.last_message_text.replace('【群公告】', '')}}
										</text>
										<text
											v-else-if="conversation.last_message_type === 'text' && !conversation.isAtAll">{{conversation.last_message_text}}</text>
										<text
											v-else-if="conversation.last_message_type === 'video'">[{{$t('chat.chat_video_message')}}]</text>
										<text
											v-else-if="conversation.last_message_type === 'audio'">[{{$t('chat.chat_voice_message')}}]</text>
										<text
											v-else-if="conversation.last_message_type === 'image'">[{{$t('chat.chat_image_message')}}]</text>
										<text
											v-else-if="conversation.last_message_type === 'file'">[{{$t('chat.chat_file_message')}}]</text>
										<text
											v-else-if="conversation.last_message_type === 'transmitImage'">[图片消息]</text>
										<text
											v-else-if="conversation.last_message_type === 'transmitvideo'">[视频消息]</text>
										<text
											v-else-if="conversation.last_message_type === 'mergeTransmit'">[合并转发消息]</text>
										<text v-else-if="conversation.last_message_type === 'order'">[自定义消息:订单]</text>
										<text v-else>[[未识别内容]]</text>
									</view>
									<view class="item-info-top_content" v-else>
										<text
											v-if="conversation.conversation_type === 'private'">{{conversation.last_message_sender_id == vuex_user.uid? $t('chat.chat_you'): `"${conversation.conversation_name}"`}}{{$t('chat.chat_recall_message')}}</text>
										<text
											v-if="conversation.conversation_type === 'group'">{{conversation.last_message_sender_id == vuex_user.uid? $t('chat.chat_you'): `"${conversation.last_message_sender_name}"`}}{{$t('chat.chat_recall_message')}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="no-conversation" v-else>
					{{$t('chat.chat_no_session')}}
				</view>
				<view class="action-container" v-if="actionPopup.visible">
					<view class="layer" @click="actionPopup.visible = false"></view>
					<view class="action-box">
						<view class="action-item" @click="topConversation">
							{{actionPopup.conversation.is_top == 1 ? $t('chat.chat_unpin') : $t('chat.chat_top')}}
						</view>
						<view class="action-item" @click="deleteConversation">{{$t('chat.chat_delete_chat')}}</view>
					</view>
				</view>
			</scroll-view>

		</view>
		<view class="note-tab" v-show="current == 1">
			<movable-area class="t-conversation-item-container note-section">
				<movable-view class="t-conversation-item" direction="horizontal" @click="$goPage('/note/group')"
					damping="100">
					<view class="avatar-box">
						<image class="t-conversation-item-avatar" src="/static/static/assets/gruopavatar.svg">
						</image>
					</view>
					<view class="t-conversation-item-content">
						<label class="tui-conversation-item-name">{{$t('chat.chat_group')}}</label>
					</view>
				</movable-view>
			</movable-area>
			<view v-if="JSON.parse(JSON.stringify(value)).length > 0" v-for="(value,key) in friendList" :key="key">
				<view class="u-m-l-24 user-title">{{ key }}</view>
				<movable-area v-for="(item,index) in value" :key="index" class="t-conversation-item-container">
					<movable-view class="t-conversation-item" direction="horizontal" @change="handleTouchMove"
						@click="goUser(item.FriendTimUserId)" damping="100" :x="xScale">
						<view class="avatar-box">
							<image class="t-conversation-item-avatar"
								:src="item.FriendAvatar == '' ? '../../static/images/avatar.jpg': item.FriendAvatar">
							</image>
						</view>
						<view class="t-conversation-item-content">
							<label class="tui-conversation-item-name">{{item.FriendName}}</label>
						</view>
					</movable-view>
				</movable-area>
			</view>
			<view class="empty-text" v-if="isEmpty">{{ $t('chat.empty_txt') }}</view>
		</view>
	</view>
</template>

<script>
	import {
		isToday,
		getDate,
		getTime
	} from '../../utils/date'
	import {
		caculateTimeago
	} from '@/components/base/common';
	import uniSegmented from "@/components/uni-segmented-control/uni-segmented-control.vue"
	import pageMixin from '@/utils/pageMixin';
	import TUIConversationItem from "@/components/tui-conversation/conversation-item/index";
	import TUIMessageList from "@/components/tui-chat/message-list/index";
	import {
		db
	} from "@/utils/sqlite";
	import sqliteSQL from "@/utils/sqliteSQL";
	// import pinyin from 'js-pinyin';
	export default {
		mixins: [pageMixin],
		data() {
			return {
				current: 0,
				conversationList: [],
				conversationIds: [],
				conversationDict: [],
				groupDict: [],
				loadedServer: false,
				xScale: 0,
				friendList: {},
				msgTotalCount: 0,
				msgCount: 0,
				status: 'nomore',
				iconType: 'flower',
				loadText: {
					loadmore: this.$t('chat.pull_up'),
					loading: this.$t('chat.loading'),
					nomore: this.$t('chat.note_no_more'),
				},
				isEmpty: false,

				unreadTotal: 0,
				conversations: [],
				conversationsDict: [],
				lastMessageDict: [],

				actionPopup: {
					conversation: null,
					visible: false
				},
				currentUser: null,

				socketClose: true,
				top: 0,
				isShowTip: false, //是否显示操作菜单
				currentTip: null,
				currentConversation: null,
				timeOut:null,
				vuex_user:{},
			}
		},
		computed: {
//			i18n() {
//				return this.$t('chat')
//			},
			list1() {
				return [{
						'name': this.$t('chat.chat')
					},
					{
						'name': this.$t('chat.contact')
					}
				]
			}
		},
		onLoad() {
		    this.vuex_user = this.$store.state.vuex_user
			this.$store.commit('checkUserLogin');
			this.loaded();
		},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload() {
		},
		onShow() {
			this.$store.commit('checkUserLogin');

			//打开SQLite数据库
			let dbname = sqliteSQL.db.dbName
			let path = '_doc/' + this.vuex_user.uid + '.db'
			let isOpen = db.isOpenDB(dbname, path)
			if (!isOpen) {
				plus.sqlite.openDatabase({
					name: dbname,
					path: path,
					success: function(res) {
						console.log("打开成功")
					},
					fail: function(e) {
						console.log('failed: ' + JSON.stringify(e))
					}
				});
			}

			//获取群组列表
			this.getServerGroupList();

			//获取消息通知未读数量
			this.getUserMsgSystemCount();

			//获取会话列表数据
			this.getSQLiteConversation();

			//连接Goeasy
			if (this.goEasy.getConnectionStatus() === 'disconnected') {
				this.connectGoEasy(); //连接goeasy
			}
			this.subscribeGroup(); //订阅群消息

			let that = this
			setTimeout(function() {
				that.getServerConversationList();
			}, 300)

			this.goEasy.im.on(this.GoEasy.IM_EVENT.CONVERSATIONS_UPDATED, (content) => {
				console.log("会变化的会话列表哦", content)
				this.renderConversations(content);
			});
		},
		components: {
			uniSegmented,
			TUIConversationItem,
			TUIMessageList
		},
		methods: {
			getMessageLastTime() {
				let that = this
				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + this.vuex_user.uid + '.db'

				let selectSql = 'SELECT * FROM im_conversation_message GROUP BY receiver_id ORDER BY timestamp DESC'
				let isOpen = db.isOpenDB(dbname, path)
				if (isOpen) {

					plus.sqlite.selectSql({
						name: dbname,
						sql: selectSql,
						success: (result) => {
							//console.log("lastMessageTime", result)
							for (let i = 0; i < result.length; i++) {
								that.lastMessageDict[result[i].receiver_id] = result[i].timestamp
							}
							console.log("that.lastMessageDict", that.lastMessageDict);
						},
						fail: (e) => {
							console.log("新增失败了", e);
						}
					})

				}
			},
			syncMessage(data) {

				let that = this
				let socketOpen = false

				uni.connectSocket({
					url: 'ws://127.0.0.1:8199/socket'
				});
				uni.onSocketOpen(function(res) {
					socketOpen = true;
				});

				uni.onSocketMessage(function(res) {

					console.log('收到服务器内容：' + res);


					uni.closeSocket();
					// for (let i = 0; i < data.length; i++) {
					// 	let conversation_id = data[i].conversation_id
					// 	let conversation_type = data[i].conversation_type
					// 	let lastMessageTime = data[i].last_message_timestamp

					// 	//同时获取消息
					// 	if (conversation_type == 'private') {
					// 		that.syncGoeasyUserMessage(conversation_id)
					// 	} else if (conversation_type == 'group') {
					// 		that.syncGoeasyGroupMessage(conversation_id)
					// 	}
					// }
				});

				uni.onSocketClose(function(res) {
					console.log('WebSocket 已关闭！');
				});
			},
			syncGoeasyUserMessage(userId) {
				let lastMessageTimeStamp = null;
				let lastMessageTime = uni.getStorageSync(userId);
				if (lastMessageTime > 0) {
					lastMessageTimeStamp = lastMessageTime
				}
				this.goEasy.im.history({
					userId: userId,
					lastTimestamp: lastMessageTimeStamp,
					limit: 10,
					onSuccess: (result) => {
						let messages = result.content;
						if (messages.length === 0) {

							console.log("没消息了，没消息了")

							//检查是否有服务消息未读
							// this.getServerMessageList();
						} else {

							console.log("取用户数据了", lastMessageTimeStamp);
							let insertData = []
							for (let i = 0; i < messages.length; i++) {

								let messageId = messages[i].messageId
								let video = messages[i].payload.video || {}
								let thumbnail = messages[i].payload.thumbnail || {}
								let senderData = messages[i].senderData || {}
								let payloadUrl = messages[i].payload.url || ''
								let videoUrl = video.url || ''
								let thumbnailUrl = thumbnail.url || ''

								//下载图片、视频、音频到本地
								this.downloadMessageFile(payloadUrl, messageId, 'payload_url')
								this.downloadMessageFile(videoUrl, messageId, 'video_url')
								this.downloadMessageFile(thumbnailUrl, messageId, 'thumbnail_url')
								this.downloadMessageFile(senderData.avatar || '', messageId, 'sender_avatar')

								//组装插入数据
								let insert = {
									'message_id': messages[i].messageId,
									'receiver_id': messages[i].receiverId || '',
									'sender_id': messages[i].senderId,
									'sender_name': senderData.name || '',
									'sender_avatar': senderData.avatar || '',
									'timestamp': messages[i].timestamp,
									'message_type': messages[i].type,
									'message_recalled': messages[i].recalled ? 1 : 0,
									'message_status': messages[i].status,
									'message_read': messages[i].read ? 1 : 0,
									'payload_text': messages[i].payload.text || '',
									'payload_name': messages[i].payload.name || '',
									'payload_content_type': messages[i].payload.contentType || '',
									'payload_url': payloadUrl,
									'payload_duration': messages[i].payload.duration || '',
									'payload_size': messages[i].payload.size || '',
									'payload_width': messages[i].payload.width || '',
									'payload_height': messages[i].payload.height || '',
									'video_name': video.name || '',
									'video_content_type': video.contentType || '',
									'video_url': videoUrl,
									'video_duration': video.duration || '',
									'video_width': video.width || '',
									'video_height': video.height || '',
									'video_size': video.size || '',
									'thumbnail_content_type': thumbnail.contentType || '',
									'thumbnail_url': thumbnailUrl,
									'thumbnail_width': thumbnail.width || '',
									'thumbnail_height': thumbnail.height || '',
								};
								let keys = Object.keys(insert)
								let keyStr = keys.toString()
								let valStr = ''
								for (let key in insert) {
									valStr += ('"' + insert[key] + '",')
								}
								valStr = valStr.substr(0, valStr.length - 1);
								let sqlStr = `INSERT INTO im_conversation_message(${keyStr}) values(${valStr})`

								insertData.push(sqlStr)
							}

							this.insertSQLiteMessageData(insertData)

							uni.setStorage({
								key: userId,
								data: messages[messages.length - 1].timestamp,
								success: function() {
									console.log('重置缓存', messages[messages.length - 1].timestamp);
								}
							});
						}
					},
					onFailed: (error) => {
						//获取失败
						console.log('获取历史消息失败:', error);
					}
				});
			},
			syncGoeasyGroupMessage(groupId) {
				let lastMessageTimeStamp = null;
				let lastMessageTime = uni.getStorageSync(groupId);
				if (lastMessageTime > 0) {
					lastMessageTimeStamp = lastMessageTime
				}
				this.goEasy.im.history({
					groupId: groupId,
					lastTimestamp: lastMessageTimeStamp,
					limit: 10,
					onSuccess: (result) => {
						let messages = result.content;
						if (messages.length === 0) {

							console.log("没消息了，没消息了")

							//检查是否有服务消息未读
							// this.getServerMessageList();
						} else {

							console.log("messages", messages)

							let insertData = []
							for (let i = 0; i < messages.length; i++) {

								let messageId = messages[i].messageId
								let video = messages[i].payload.video || {}
								let thumbnail = messages[i].payload.thumbnail || {}
								let senderData = messages[i].senderData || {}
								let payloadUrl = messages[i].payload.url || ''
								let videoUrl = video.url || ''
								let thumbnailUrl = thumbnail.url || ''

								//下载图片、视频、音频到本地
								this.downloadMessageFile(payloadUrl, messageId, 'payload_url')
								this.downloadMessageFile(videoUrl, messageId, 'video_url')
								this.downloadMessageFile(thumbnailUrl, messageId, 'thumbnail_url')
								this.downloadMessageFile(senderData.avatar || '', messageId, 'sender_avatar')

								//组装插入数据
								let insert = {
									'message_id': messages[i].messageId,
									'receiver_id': messages[i].receiverId,
									'sender_id': messages[i].senderId,
									'sender_name': senderData.name || '',
									'sender_avatar': senderData.avatar || '',
									'timestamp': messages[i].timestamp,
									'message_type': messages[i].type,
									'message_recalled': messages[i].recalled,
									'message_status': messages[i].status,
									'message_read': messages[i].read,
									'payload_text': messages[i].payload.text || '',
									'payload_name': messages[i].payload.name || '',
									'payload_content_type': messages[i].payload.contentType || '',
									'payload_url': payloadUrl,
									'payload_duration': messages[i].payload.duration || '',
									'payload_size': messages[i].payload.size || '',
									'payload_width': messages[i].payload.width || '',
									'payload_height': messages[i].payload.height || '',
									'video_name': video.name || '',
									'video_content_type': video.contentType || '',
									'video_url': videoUrl,
									'video_duration': video.duration || '',
									'video_width': video.width || '',
									'video_height': video.height || '',
									'video_size': video.size || '',
									'thumbnail_content_type': thumbnail.contentType || '',
									'thumbnail_url': thumbnailUrl,
									'thumbnail_width': thumbnail.width || '',
									'thumbnail_height': thumbnail.height || '',
								};
								let keys = Object.keys(insert)
								let keyStr = keys.toString()
								let valStr = ''
								for (let key in insert) {
									valStr += ('"' + insert[key] + '",')
								}
								valStr = valStr.substr(0, valStr.length - 1);
								let sqlStr = `INSERT INTO im_conversation_message(${keyStr}) values(${valStr})`

								insertData.push(sqlStr)
							}

							this.insertSQLiteMessageData(insertData)

							uni.setStorage({
								key: groupId,
								data: messages[messages.length - 1].timestamp,
								success: function() {
									console.log('重置缓存', messages[messages.length - 1].timestamp);
								}
							});
						}
					},
					onFailed: (error) => {
						//获取失败
						console.log('获取历史消息失败:', error);
					}
				});
			},
			downloadMessageFile(url, messageId, key) {
				let that = this
				console.log("下载消息的图片", url)
				if (url != '' && url.indexOf('http') == 0) {
					uni.downloadFile({
						url: url,
						success: (res) => {
							if (res.statusCode === 200) {
								uni.saveFile({
									tempFilePath: res.tempFilePath,
									success: function(result) {

										console.log("下载好了", result.savedFilePath)
										//更新消息数据
										that.updateSQLiteMessageData(messageId, result
											.savedFilePath, key)
									},
								})
							}
						}
					})
				}
			},
			insertSQLiteMessageData(insertData) {

				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + this.vuex_user.uid + '.db'

				//打开数据库
				let isOpen = db.isOpenDB(dbname, path)
				if (isOpen) {

					//开启事务
					plus.sqlite.transaction({
						name: dbname,
						operation: 'begin'
					})

					plus.sqlite.executeSql({
						name: dbname,
						sql: insertData,
						success: (e) => {
							console.log("历史消息新增成功", e);
						},
						fail: (e) => {
							console.log("历史消息新增失败", e);
						}
					})

					//提交事务
					plus.sqlite.transaction({
						name: dbname,
						operation: 'commit'
					})

				} else {

					//开启事务
					plus.sqlite.transaction({
						name: dbname,
						operation: 'begin'
					})

					plus.sqlite.openDatabase({
						name: dbname,
						path: path,
						success: function(res) {
							plus.sqlite.executeSql({
								name: dbname,
								sql: insertData,
								success: (e) => {
									console.log("历史消息新增成功", e);
								},
								fail: (e) => {
									console.log("历史消息新增失败", e);
								}
							})
						},
						fail: function(e) {
							console.log('failed: ' + JSON.stringify(e))
						}
					});
					//提交事务
					plus.sqlite.transaction({
						name: dbname,
						operation: 'commit'
					})

				}

			},
			updateSQLiteMessageData(messageId, url, key) {

				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + this.vuex_user.uid + '.db'
				let updateSql = `UPDATE im_conversation_message SET ${key} = "${url}" WHERE message_id = "${messageId}";`

				//打开数据库
				let isOpen = db.isOpenDB(dbname, path)
				if (isOpen) {

					plus.sqlite.executeSql({
						name: dbname,
						sql: updateSql,
						success: (e) => {
							console.log("消息图片更新成功", e);
						},
						fail: (e) => {
							console.log("消息图片更新失败", e);
						}
					})
				} else {
					plus.sqlite.openDatabase({
						name: dbname,
						path: path,
						success: function(res) {
							plus.sqlite.executeSql({
								name: dbname,
								sql: updateSql,
								success: (e) => {
									console.log("消息图片更新成功", e);
								},
								fail: (e) => {
									console.log("消息图片更新失败", e);
								}
							})
						},
						fail: function(e) {
							console.log('failed: ' + JSON.stringify(e))
						}
					});
				}
			},
			connectGoEasy() {
				// uni.showLoading();
				this.goEasy.connect({
					id: this.vuex_user.uid,
					data: {
						name: this.vuex_user.uname,
						avatar: this.vuex_user.avatar
					},
					onSuccess: () => {
						console.log('GoEasy connect successfully.')
					},
					onFailed: (error) => {
						console.log('Failed to connect GoEasy, code:' + error.code + ',error:' + error
							.content);
					},
					onProgress: (attempts) => {
						console.log('GoEasy is connecting', attempts);
					}
				});

				//订阅Goeasy消息
				this.goEasy.pubsub.subscribe({
					channel: "user" + this.vuex_user.uid,
					onMessage: function(message) {
						console.log("Channel:" + message.channel + " content:" +
							message.content);
					},
					onSuccess: function() {
						console.log("Channel订阅成功。");
					},
					onFailed: function(error) {
						console.log("Channel订阅失败, 错误编码：" + error.code + " 错误信息：" +
							error.content)
					}
				});
			},
			// 加载最新的会话列表
			loadConversations() {
				this.goEasy.im.latestConversations({
					onSuccess: (result) => {
						let content = result.content;
						this.renderConversations(content);
						this.getServerConversationList();
					},
					onFailed: (error) => {
						console.log('获取最新会话列表失败, error:', error);
					}
				});
			},
			listenConversationUpdate() {
				console.log("我来变化了")
				// 监听会话列表变化
				this.goEasy.im.on(this.GoEasy.IM_EVENT.CONVERSATIONS_UPDATED, (content) => {
					console.log("会变化的会话列表哦", content)
					// this.renderConversations(content);
					// this.getServerConversationList();
				});
			},
			subscribeGroup() {
				let that = this;
				that.$http.get('/mgr/user/group/get', {
					uid: that.vuex_user.uid
				}).then(function(res) {
					console.log("群 ID", res)
					that.goEasy.im.subscribeGroup({
						groupIds: res,
						onSuccess: function() {
							console.log('订阅群消息成功');
						},
						onFailed: function(error) {
							console.log('订阅群消息失败:', error);
						}
					});
				});
			},
			topConversation() { //会话置顶
				this.currentTip = 0
				uni.showLoading({
					mask: true
				});
				let actionPopup = this.actionPopup;
				actionPopup.visible = false;

				let conversation = actionPopup.conversation;
				let isTop = conversation.is_top == 1 ? true : false;
				let failedDescription = isTop ? 'error' : 'error';
				let is_top = conversation.is_top == 1 ? 0 : 1
				let conversationId = ''
				if (conversation.conversation_type == 'group') {
					conversationId = 'GROUP' + conversation.conversation_id
				} else if (conversation.conversation_type == 'private') {
					conversationId = 'C2C' + conversation.conversation_id
				}

				console.log("conversationId", conversationId)
				console.log("is_top", is_top)
				this.$http.post('/mgr/user/chat/conversation/top', {
					'conversation_id': conversationId,
					'is_top': is_top
				}).then(res => {
					console.log("更新置顶成功......")
				}).catch(err => {
					console.log("更新失败拉", )
				})

				this.conversations[this.currentConversation].is_top = is_top == 1 ? true : false
				if (conversation.conversation_type === this.GoEasy.IM_SCENE.PRIVATE) {
					this.goEasy.im.topPrivateConversation({
						userId: conversation.conversation_id,
						top: !isTop,
						onSuccess: () => {
							uni.hideLoading();
							this.updateConversationInfo(
								`UPDATE im_conversation SET is_top="${is_top}" WHERE conversation_id="${conversation.conversation_id}"`
							)
						},
						onFailed: (error) => {
							uni.hideLoading();
							this.updateConversationInfo(
								`UPDATE im_conversation SET is_top="${is_top}" WHERE conversation_id="${conversation.conversation_id}"`
							)
							console.log(error);
						}
					});
				} else {
					this.goEasy.im.topGroupConversation({
						groupId: conversation.conversation_id,
						top: !isTop,
						onSuccess: () => {
							uni.hideLoading();
							this.updateConversationInfo(
								`UPDATE im_conversation SET is_top="${is_top}" WHERE conversation_id="${conversation.conversation_id}"`
							)
						},
						onFailed: (error) => {
							this.updateConversationInfo(
								`UPDATE im_conversation SET is_top="${is_top}" WHERE conversation_id="${conversation.conversation_id}"`
							)
							uni.hideLoading();
							console.log(error);

						}
					});
				}
				setTimeout(() => {
					this.isShowTip = false
					this.currentConversation = null
					this.currentTip = null
				}, 200)
			},
			deleteConversation() {
				let that = this
				this.currentTip = 1
				uni.showLoading({
					mask: true
				});
				let failedDescription = 'delete error';
				let conversation = this.actionPopup.conversation;
				this.actionPopup.visible = false;
				console.log("conversation", conversation)

				if (conversation.conversation_type === this.GoEasy.IM_SCENE.PRIVATE) {
					this.goEasy.im.removePrivateConversation({
						userId: conversation.conversation_id,
						onSuccess: function() {
							that.updateConversationInfo(
								`DELETE FROM im_conversation WHERE conversation_id="${conversation.conversation_id}"`
							)
							uni.hideLoading()
						},
						onFailed: function(error) {
							that.updateConversationInfo(
								`DELETE FROM im_conversation WHERE conversation_id="${conversation.conversation_id}"`
							)
							uni.hideLoading();
							console.log(error);
						}
					});
				} else {
					this.goEasy.im.removeGroupConversation({
						groupId: conversation.conversation_id,
						onSuccess: function() {
							that.updateConversationInfo(
								`DELETE FROM im_conversation WHERE conversation_id="${conversation.conversation_id}"`
							)
							uni.hideLoading()
						},
						onFailed: function(error) {
							that.updateConversationInfo(
								`DELETE FROM im_conversation WHERE conversation_id="${conversation.conversation_id}"`
							)
							uni.hideLoading();
							console.log(error);
						}
					});
				}
				setTimeout(() => {
					this.isShowTip = false
					this.currentConversation = null
					this.currentTip = null
				}, 200)
			},
			updateConversationInfo(updateSql) {
				let that = this
				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + this.vuex_user.uid + '.db'

				//打开数据库
				let isOpen = db.isOpenDB(dbname, path)
				if (isOpen) {
					plus.sqlite.executeSql({
						name: dbname,
						sql: updateSql,
						success: (e) => {
							console.log(" 会话更新成功", e);
							that.getSQLiteConversation()
							that.getServerConversationList()
						},
						fail: (e) => {
							console.log("会话更新失败", e);
						}
					})
				} else {
					plus.sqlite.openDatabase({
						name: dbname,
						path: path,
						success: function(res) {
							plus.sqlite.executeSql({
								name: dbname,
								sql: updateSql,
								success: (e) => {
									console.log(" 会话更新成功", e);
									that.getSQLiteConversation()
									that.getServerConversationList()
								},
								fail: (e) => {
									console.log(" 会话更新失败", e);
								}
							})
						},
						fail: function(e) {
							console.log('failed: ' + JSON.stringify(e))
						}
					});
				}
			},
			renderConversations(content) {
				console.log("进来这里了嘛？222222")
				let that = this
				let uid = this.vuex_user.uid || 0
				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + uid + '.db'
				let insertData = []
				let conversationsData = []
				let conversations = content.conversations
				let groupMemberDict = uni.getStorageSync('groupMemberDict') || []

				console.log("获取消息来了content", conversations)
				console.log("groupMemberDict", groupMemberDict)
				console.log("that.conversationsDict", that.conversationsDict)

				for (let i = 0; i < conversations.length; i++) {

					let groupId = parseInt(conversations[i].groupId) || 0;
					let groupAvatar = conversations[i].data.avatar || '';
					let text = conversations[i].lastMessage.payload.text || '';
					let senderData = conversations[i].lastMessage.senderData || {};
					let isAtAll = false;
					if (text.indexOf('【群公告】') !== -1) {
						text = text.replace('【群公告】', '');
						conversations[i].lastMessage.payload.text = text;
						isAtAll = true;
					}
					let conversation_id = conversations[i].userId || ''
					if (conversation_id == '' && conversations[i].groupId != '') {
						conversation_id = conversations[i].groupId
					}

					//检查本地会话最新时间是否大于 goeasy 最新会话时间	
					if (that.conversationsDict[conversation_id] === undefined || (that.conversationsDict[conversation_id]
							.last_message_timestamp >= conversations[i].lastMessage
							.timestamp && conversations[i].unread == that.conversationsDict[conversation_id].unread)) {
						continue
					}
					console.log("来新活拉", conversations[i])

					for (let k = 0; k < that.conversations.length; k++) {
						if (that.conversations[k].conversation_id == conversation_id) {
							let userName = uni.getStorageSync('groupMemberUserName-' + conversations[i].lastMessage
								.senderId) || ''
							console.log("userName", userName)
							that.conversations[k]['unread'] = conversations[i].unread
							that.conversations[k]['last_message_id'] = conversations[i].lastMessage.messageId
							that.conversations[k]['last_message_type'] = conversations[i].lastMessage.type
							that.conversations[k]['last_message_timestamp'] = conversations[i].lastMessage.timestamp
							that.conversations[k]['last_message_status'] = conversations[i].lastMessage.status
							that.conversations[k]['last_message_sender_id'] = conversations[i].lastMessage.senderId || ''
							that.conversations[k]['last_message_sender_name'] = senderData.name || ''
							if (userName !== '') {
								that.conversations[k]['last_message_sender_name'] = userName
								senderData.name = userName
							}
							that.conversations[k]['last_message_recalled'] = conversations[i].lastMessage.recalled
							that.conversations[k]['last_message_read'] = conversations[i].lastMessage.read
							that.conversations[k]['last_message_text'] = conversations[i].lastMessage.payload.text || ''
							that.conversations[k]['last_message_content_type'] = conversations[i].lastMessage.payload
								.contentType || ''
						}
					}

					let data = {
						'is_at_all': conversations[i].isAtAll ? 1 : 0,
						'unread': conversations[i].unread,
						'is_top': that.conversationsDict[conversation_id].is_top,
						'last_message_id': conversations[i].lastMessage.messageId,
						'last_message_group_id': conversations[i].lastMessage.groupId || '',
						'last_message_type': conversations[i].lastMessage.type,
						'last_message_timestamp': conversations[i].lastMessage.timestamp,
						'last_message_status': conversations[i].lastMessage.status,
						'last_message_sender_id': conversations[i].lastMessage.senderId || '',
						'last_message_sender_name': senderData.name || '',
						'last_message_recalled': conversations[i].lastMessage.recalled ? 1 : 0,
						'last_message_read': conversations[i].lastMessage.read ? 1 : 0,
						'last_message_text': conversations[i].lastMessage.payload.text || '',
						'last_message_content_type': conversations[i].lastMessage.payload.contentType || '',
						'last_message_height': conversations[i].lastMessage.payload.height || '',
						'last_message_width': conversations[i].lastMessage.payload.width || '',
						'last_message_size': conversations[i].lastMessage.payload.size || '',
						'last_message_name': conversations[i].lastMessage.payload.name || '',
						'last_message_duration': conversations[i].lastMessage.payload.duration || '',
						'last_message_url': conversations[i].lastMessage.payload.url || '',
					};
					let keys = Object.keys(data)
					let keyStr = keys.toString()
					let valStr = ''
					for (let key in data) {
						valStr += key + ('="' + data[key] + '",')
					}
					valStr = valStr.substr(0, valStr.length - 1);
					let sqlStr = `UPDATE im_conversation SET ${valStr} WHERE conversation_id="${conversation_id}"`

					insertData.push(sqlStr)
				}

				console.log("that.conversations", that.conversations)

				// 会话列表重新排序
				if (insertData.length > 0) {
					that.conversationSort()
				}

				if (uid > 0 && insertData.length > 0) {

					let dbname = sqliteSQL.db.dbName
					let path = '_doc/' + uid + '.db'

					//打开数据库
					let isOpen = db.isOpenDB(dbname, path)
					if (isOpen) {

						plus.sqlite.executeSql({
							name: dbname,
							sql: insertData,
							success: (e) => {
								console.log("修改成功了哈", e);
							},
							fail: (e) => {
								console.log("修改失败了", e);
							}
						})
					}
				}

				let unreadTotal = content.unreadTotal;
				this.setUnreadAmount(unreadTotal);
				this.saveConversationAvatar();
			},
			setUnreadAmount(unreadTotal) {
				this.unreadTotal = unreadTotal;
				let msgTotalCount = this.unreadTotal + this.msgTotalCount
				let msgCount = this.unreadTotal + this.msgCount
				if (msgTotalCount > 0) {
					plus.runtime.setBadgeNumber(msgTotalCount)
				} else {
					plus.runtime.setBadgeNumber(0)
				}
				if (msgCount > 0) {
					uni.setTabBarBadge({
						index: 2,
						text: msgCount.toString()
					});
				} else {
					uni.removeTabBarBadge({
						index: 2
					});
				}
			},
			navigateToChat(conversation) {
				if (!this.isShowTip) {
					let lastMessageTime = this.lastMessageDict[conversation.conversation_id] || 0
					let path = conversation.conversation_type === this.GoEasy.IM_SCENE.PRIVATE ?
						'./room/index?to=' + conversation.conversation_id + '&conversation_name=' + conversation
						.conversation_name + '&conversation_avatar=' + conversation.conversation_avatar +
						'&lastMessageTime=' + lastMessageTime :
						'./group/room/index?to=' + conversation.conversation_id + '&conversation_name=' + conversation
						.conversation_name + '&conversation_avatar=' + conversation.conversation_avatar +
						'&lastMessageTime=' + lastMessageTime;
					uni.navigateTo({
						url: path
					});
				}
			},
			showAction(conversation) {
				this.actionPopup.conversation = conversation;
				this.actionPopup.visible = true;
			},
			loaded() {},
			getUserFriendList() {
				this.$http.get('/mgr/user/friend/data', {}).then(res => {
					this.friendList = this.sortMember(res);
					if (res.length == 0) {
						this.isEmpty = true
					}
					console.log(this.friendList)
				});
			},
			sortMember(arr) {

				var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
				var resList = {} //排序分类后的对象
				let pattern1 = new RegExp("[\u4E00-\u9FA5]+"); //中文
				let pattern2 = new RegExp("[A-Za-z]+"); //英文					   					   	   					   
				letters.map((item, i) => {
					resList[item] = []
					arr.forEach(item1 => {
						console.log(item1)
						//验证改昵称是以中文、英文还是其他字符开头
						let firstStr = item1.FriendName.substring(0, 1)

						let str = '' //定义首字母

						if (pattern1.test(firstStr)) {
							//如果以中文开头，则转换为拼音,并获取首字母

							str = pinyin.getFullChars(firstStr).substring(0, 1)
						} else if (pattern2.test(firstStr)) {
							//如果以英文字母开头

							str = firstStr.toUpperCase()
						}
						if (str == item) {
							resList[item].push(item1)
						}
					})

				})

				resList['#'] = []
				//其他字符开头的成员					
				arr.forEach(item1 => {
					//验证改昵称是以中文、英文还是其他字符开头
					let firstStr = item1.FriendName.substring(0, 1)
					let str = '' //定义首字母

					if (!pattern2.test(firstStr) && !pattern1.test(firstStr)) {
						//如果以中文开头，则转换为拼音,并获取首字母

						resList['#'].push(item1)
					}
				})
				console.log(resList)
				return resList
			},
			tabChange(index) {
				this.current = index
				if (this.current == 1) {
					this.getUserFriendList();
				} else if (this.current == 0) {
					this.subscribeGroup();
					this.listenConversationUpdate(); //监听会话列表变化
				}
			},
			getServerConversationList() {
				console.log("来饿了来饿了来饿了来饿了来饿了来饿了来饿了来饿了")
				let that = this
				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + this.vuex_user.uid + '.db'
				let conversationIds = []


				console.log("进来获取服务了", that.conversations)

				//获取会话列表数据
				that.conversations.forEach(item => {
					let conversationId = ''
					if (item.conversation_type == 'group') {
						conversationId = 'GROUP' + item.conversation_id
					} else if (item.conversation_type == 'private') {
						conversationId = 'C2C' + item.conversation_id
					}
					conversationIds.push(conversationId)
				})

				if (conversationIds.length > 0) {

					that.$http.get('/mgr/user/chat/conversation/data', {
						conversation_ids: conversationIds
					}).then(res => {
						console.log("res", res)
						if (res == null || res === undefined) {
							return;
						}

						if (res.length > 0) {
							let historyConversation = []
							let insertData = []
							for (let i = 0; i < res.length; i++) {
								let groupId = parseInt(res[i].groupId) || 0;
								let groupAvatar = res[i].data.avatar || '';
								let text = res[i].lastMessage.payload.text || '';
								let senderData = res[i].lastMessage.senderData || {};
								let isAtAll = false;
								if (text.indexOf('【群公告】') !== -1) {
									text = text.replace('【群公告】', '');
									res[i].lastMessage.payload.text = text;
									isAtAll = true;
								}
								let conversation_id = res[i].userId || ''
								if (conversation_id == '0' && res[i].groupId != '') {
									conversation_id = res[i].groupId
								}

								if (groupAvatar != '' && groupAvatar.indexOf('http') == 0) {
									uni.downloadFile({
										url: groupAvatar,
										success: (res) => {
											if (res.statusCode === 200) {
												uni.saveFile({
													tempFilePath: res.tempFilePath,
													success: function(result) {

														let updateSql =
															`UPDATE im_conversation SET conversation_avatar="${result.savedFilePath}" WHERE conversation_id="${conversation_id}"`
														plus.sqlite.executeSql({
															name: sqliteSQL.db
																.dbName,
															sql: updateSql,
															success: (e) => {
																console.log(
																	"后面修改成功了哈",
																	res)
															},
															fail: (e) => {
																console.log(
																	"后面修改失败了哈",
																	err)
															}
														})
														historyConversation[i]
															.conversation_avatar = result
															.savedFilePath
													},
												})
											}
										}
									})
								}

								let data = {
									'conversation_id': conversation_id,
									'conversation_name': res[i].data.name,
									'conversation_avatar': groupAvatar,
									'conversation_type': res[i].type,
									'is_at_all': res[i].isAtAll ? 1 : 0,
									'is_top': res[i].top ? 1 : 0,
									'unread': res[i].unread,
									'last_message_id': res[i].lastMessage.messageId,
									'last_message_group_id': res[i].lastMessage.groupId || '',
									'last_message_type': res[i].lastMessage.type,
									'last_message_timestamp': res[i].lastMessage.timestamp,
									'last_message_status': res[i].lastMessage.status,
									'last_message_sender_id': res[i].lastMessage.senderId || '',
									'last_message_sender_name': senderData.name || '',
									'last_message_recalled': res[i].lastMessage.recalled ? 1 : 0,
									'last_message_read': res[i].lastMessage.read ? 1 : 0,
									'last_message_text': res[i].lastMessage.payload.text || '',
									'last_message_content_type': res[i].lastMessage.payload.contentType || '',
									'last_message_height': res[i].lastMessage.payload.height || '',
									'last_message_width': res[i].lastMessage.payload.width || '',
									'last_message_size': res[i].lastMessage.payload.size || '',
									'last_message_name': res[i].lastMessage.payload.name || '',
									'last_message_duration': res[i].lastMessage.payload.duration || '',
									'last_message_url': res[i].lastMessage.payload.url || '',
								};
								let keys = Object.keys(data)
								let keyStr = keys.toString()
								let valStr = ''
								for (let key in data) {
									valStr += ('"' + data[key] + '",')
								}
								valStr = valStr.substr(0, valStr.length - 1);
								let sqlStr = `REPLACE INTO im_conversation(${keyStr}) values(${valStr})`

								historyConversation.push(data)
								insertData.push(sqlStr)
							}

							//补充到会话列表
							that.conversations = [...that.conversations, ...historyConversation];

							//处理会话列表排序
							that.conversationSort()

							//打开数据库
							let isOpen = db.isOpenDB(dbname, path)
							if (isOpen) {

								plus.sqlite.executeSql({
									name: dbname,
									sql: insertData,
									success: (e) => {
										console.log("服务的新增成功了哈", e);
									},
									fail: (e) => {
										console.log("服务的新增失败了", e);
									}
								})
							}
						}
					});
				}

			},
			conversationSort() {
				console.log("来排序拉....", this.conversations)
				this.conversations.sort((a, b) => {
					if (a.is_top == b.is_top) {
						return b.last_message_timestamp - a.last_message_timestamp
					}
					return b.is_top - a.is_top
					if (a.is_top == b.is_top) {}
					return b.last_message_timestamp - a.last_message_timestamp
				})
			},
			getServerGroupList() {
				let that = this;
				that.$http.get('/mgr/user/group/list/data', {}).then(res => {
					let groupDict = [];
					for (let i = 0; i < res.length; i++) {
						groupDict[res[i].Gid] = res[i];
					}
					that.groupDict = groupDict;
				});
			},
			saveConversationAvatar() {
				let that = this
				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + this.vuex_user.uid + '.db'

				let selectSql = 'SELECT * FROM im_conversation ORDER BY last_message_timestamp DESC'
				let isOpen = db.isOpenDB(dbname, path)
				if (isOpen) {

					plus.sqlite.selectSql({
						name: dbname,
						sql: selectSql,
						success: (result) => {
							//保存会话列表头像
							for (let i = 0; i < result.length; i++) {
								let groupId = parseInt(result[i].conversation_id) || 0
								let groupAvatar = result[i].conversation_avatar || ''
								let conversation_id = result[i].conversation_id || ''

								if (groupId > 0 && groupAvatar === '') {
									let groupInfo = this.groupDict[groupId] || {};
									let avatar = groupInfo.GroupAvatar || '';
									if (avatar === '') {
										avatar = '../../static/images/avatar.jpg'
									}
									groupAvatar = avatar
								}

								if (groupAvatar != '' && groupAvatar.indexOf('http') == 0) {
									uni.downloadFile({
										url: groupAvatar,
										success: (res) => {
											if (res.statusCode === 200) {
												uni.saveFile({
													tempFilePath: res.tempFilePath,
													success: function(result) {

														let updateSql =
															`UPDATE im_conversation SET conversation_avatar="${result.savedFilePath}" WHERE conversation_id="${conversation_id}"`
														plus.sqlite.executeSql({
															name: sqliteSQL.db
																.dbName,
															sql: updateSql,
															success: (e) => {
																console
																	.log(
																		"后面修改成功了哈"
																	)
															},
															fail: (e) => {
																console
																	.log(
																		"后面修改失败了哈"
																	)
															}
														})
													}
												})
											}
										}
									})
								}
							}
						},
						fail: (e) => {
							console.log("新增失败了", e);
						}
					})
				}
			},

			//注销登录
			outLoginBtn() {
				let promise = this.tim.logout();
				promise.then(res => {
					this.$store.commit('reset')
					uni.reLaunch({
						url: '../index/index'
					})
				}).catch(err => {
					console.log('退出失败')
				});
			},
			//聊天的节点加上外层的div
			nodesFliter(str) {
				let nodeStr = '<div style="align-items: center;word-wrap:break-word;">' + str + '</div>'
				return nodeStr
			},
			//切换tab
			changeTabBtn(_index) {
				this.isActive = _index

				this.subscribeGroup();
				this.listenConversationUpdate(); //监听会话列表变化
				this.loadConversations(); //加载会话列表
			},
			handleRoute(id, type) {
				if (type === 'GROUP') {
					const url = `./group/room/index?conversationID=${id}`;
					uni.navigateTo({
						url
					});
				} else {
					const url = `./room/index?conversationID=${id}`;
					uni.navigateTo({
						url
					});
				}
			},
			closeTip() {
				this.isShowTip = false
				this.currentConversation = null
				this.currentTip = null
			},
			handletouchmove() {  
			     clearTimeout(this.timeOut); //清除定时器    
			     this.timeOut = 0;  
			 }, 
			longPress(conversation, key) {
				this.currentConversation = key
				console.log("选中拉", this.currentConversation)
				 this.timeOut = setTimeout(() => {
					this.isShowTip = false
					setTimeout(() => {
						this.isShowTip = true
					}, 200)
					this.actionPopup.conversation = conversation;
					this.top = 150 * key + 75;
				}, 100)
				this.actionPopup.conversation = conversation;
			},
			touchStart() {
				console.log("手指点击了哦")
			},
			touchend() {
				console.log("手指松开了哦")
			},
			toRoom(item) {
				if (item.type == 'C2C') {
					this.$store.commit('updateConversationActive', item)
					this.$goPage('/note/room');
				} else {
					this.$goPage('/note/group/room', {
						groupId: item.groupProfile.groupID,
						groupName: item.groupProfile.name
					});
				}
			},
			// 用户个人主页
			goUser(uid) {
				if (uid > 1) {
					uni.navigateTo({
						url: '/pages/user/index?uid=' + uid + '&isFromContact=1'
					});
				}
			},
			getUserMsgSystemCount() {
				this.$http.get('/msg/system/type/count', {
					type: 2
				}).then(res => {
					this.msgCount = res.count2
					this.msgTotalCount = res.totalCount
				});
			},
			handleTouchMove(e) {
				if (!this.lock) {
					this.last = e.detail.x;
					this.lock = true;
				}

				if (this.lock && e.detail.x - this.last < -5) {
					this.setData({
						xScale: -75
					});
					setTimeout(() => {
						this.lock = false;
					}, 2000);
				} else if (this.lock && e.detail.x - this.last > 5) {
					this.setData({
						xScale: 0
					});
					setTimeout(() => {
						this.lock = false;
					}, 2000);
				}
			},
			getSQLiteConversation() {
				let that = this
				let dbname = sqliteSQL.db.dbName
				let path = '_doc/' + this.vuex_user.uid + '.db'

				let selectSql = 'SELECT * FROM im_conversation ORDER BY is_top DESC,last_message_timestamp DESC'
				let isOpen = db.isOpenDB(dbname, path)
				if (isOpen) {

					plus.sqlite.selectSql({
						name: dbname,
						sql: selectSql,
						success: (result) => {

							console.log("result", result)

							let conversationsDict = []
							for (let i = 0; i < result.length; i++) {
								conversationsDict[result[i].conversation_id] = result[i]
							}
							that.conversations = result
							that.conversationsDict = conversationsDict
							console.log("that.conversationsDict", that.conversationsDict)
						},
						fail: (e) => {
							console.log("新增失败了", e);
						}
					})

				}
			},
			lastMessageSenderName(senderName) {
				console.log("senderName", senderName)
				return senderName
			},
		},
		onPullDownRefresh() {
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
	}
</script>

<style lang="scss" scoped>
	@import "./index.css";

	@keyframes appear {
		0% {
			opacity: 0
		}

		25% {
			opacity: 0.7
		}

		100% {
			opacity: 1
		}
	}

	.note {
		// padding-bottom: 88rpx;
		padding-top: calc(130rpx + var(--status-bar-height));
	}

	.user-title {
		color: #9a9a9a ;
		font-size: 26rpx;
	}

	.empty-text {
		position: absolute;
		top: 600rpx;
		left: 50%;
		transform: translateX(-50%);
	}

	.note-header {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 99;
		padding-top: var(--status-bar-height);
		background-color: #EFEFEF;
	}

	.note-header_tabs {
		width: 60%;
		padding: 30rpx 0 0;
		margin: 0 auto;
	}

	.line {
		width: 2rpx;
		height: 26rpx;
		background-color: #cdcdcd;
	}

	.line1 {
		position: absolute;
		left: 140rpx;
	}

	.line2 {
		position: absolute;
		left: 50%;
	}

	.line3 {
		position: absolute;
		right: 140rpx;
	}

	.tab {
		text-align: center;
		color: #8D8D8D;
	}

	.tab-content {
		width: 100%;
		font-size: 32rpx ;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		color: #000000;
		background-color: transparent ;
	}

	.u-tab-bar {
		margin-top: 10rpx ;
	}

	.tab-active {
		color: #000 ;
	}

	.search-btn {
		position: absolute;
		left: 40rpx;
	}

	.note-add_btn {
		position: absolute;
		right: 50rpx;
		padding-bottom: 10rpx;
	}

	.icon-add-friend {
		color: #9F9F9F;
		font-size: 38rpx;

	}

	.head-tab-icon {
		margin-right: 17rpx;
		font-size: 36rpx;
	}

	.head-tab-text {
		font-size: 35rpx;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		color: #8D8D8D;
		line-height: 40rpx;
	}

	.note-section {
		margin-bottom: 20rpx;
		margin-top: -10rpx;
	}

	.note-item {
		background-color: #fff;
		height: 106rpx;
		padding: 0 24rpx 0 18rpx;

		&_avatar {
			position: relative;
			margin-right: 24rpx;
		}

		&_content {
			height: 100%;
			display: flex;
			justify-content: center;
			flex-direction: column;

			&--name {
				font-size: 32rpx;
			}

			&--text {
				font-size: 24rpx;
				color: #949C9E;
			}
		}

		&_time {
			font-size: 24rpx;
			height: 76rpx;
			color: #949C9E;
		}
	}


	page {
		height: 100%;
	}

	.conversations {
		width: 750rpx;
		overflow-x: hidden;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		height: 100%;

	}

	.tooltips {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		display: inline-block;
		background-color: #fff;
		border-radius: 10rpx;
		box-shadow: 0 -10rpx 20rpx #d9dcdc, 10rpx 0 20rpx #d9dcdc, 0 10rpx 20rpx #d9dcdc, -10rpx 0 20rpx #d9dcdc;
		user-select: none;
		-webkit-touch-callout: none;

		&.tooltips-active {
			transition: transform 0.2s ease-in-out 0s;
			transform: scale(1, 1);
		}

		&.tooltips-inactive {
			transition: transform 0s ease-in-out 0s;
			transform: scale(0, 0);
		}

		.tooltips-item {
			padding: 24rpx 60rpx;
			font-size: 34rpx;
			font-weight: 400;
		}

		.current-tip {
			background-color: #f1f1f1;
		}
	}

	.conversations .scroll-item {
		height: 152rpx;
		display: flex;
		align-items: center;
		padding-left: 32rpx;
	}

	.conversations .current-item {
		background-color: #e7eaea;
	}

	.conversations .scroll-item .head-icon {
		width: 96rpx;
		height: 96rpx;
		margin-right: 28rpx;
		border-radius: 16rpx;
	}

	.conversations .scroll-item_info {
		height: 151rpx;
		width: 590rpx;
		padding-right: 32rpx;
		box-sizing: border-box;
		border-bottom: 1px solid #EFEFEF;
	}

	.conversations .scroll-item_info .item-info-top {
		margin-top: 20rpx;
		padding-bottom: 16rpx;
		height: 60rpx;
		line-height: 60rpx;
		display: flex;
		justify-content: space-between;

	}

	.conversations .item-info-top_name {
		font-size: 34rpx;
		color: #262628;
		width: 460rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.conversations .item-info-top_time {
		font-size: 26rpx;
		margin-top: -8rpx;
		color: rgba(179, 179, 179, 0.8);
		font-family: Source Han Sans CN;
		white-space: nowrap;
	}

	.conversations .item-info-bottom {
		height: 40rpx;
		line-height: 40rpx;
		overflow: hidden;
	}

	.conversations .item-info-bottom-item {
		display: flex;
		justify-content: space-between;
	}

	.item-info-bottom .item-info-top_content {
		font-size: 30rpx;
		color: #b3b3b3;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;

	}

	.item-info-bottom .item-info-bottom_action {
		width: 50rpx;
		height: 50rpx;
		font-size: 20rpx;
		background: url("../../static/images/action.png") no-repeat center;
		background-size: 28rpx 30rpx;
	}

	.no-conversation {
		width: 100%;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 28rpx;
		color: #9D9D9D;
	}

	.item-head {
		position: relative;
	}

	.item-head .item-head_unread {
		padding: 6rpx;
		background-color: #EE593C;
		color: #FFFFFF;
		font-size: 24rpx;
		line-height: 28rpx;
		border-radius: 24rpx;
		min-width: 24rpx;
		min-height: 24rpx;
		text-align: center;
		position: absolute;
		top: 0;
		right: 15rpx;
	}

	.action-container {
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0;
		left: 0;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.action-container .layer {
		position: absolute;
		top: 0;
		left: 0;
		background: rgba(51, 51, 51, 0.5);
		width: 100%;
		height: 100%;
		z-index: 99;
	}

	.action-box {
		width: 400rpx;
		height: 240rpx;
		background: #ffffff;
		position: relative;
		z-index: 100;
		border-radius: 20rpx;
		overflow: hidden;
	}

	.action-item {
		text-align: center;
		line-height: 120rpx;
		font-size: 34rpx;
		color: #262628;
		border-bottom: 1px solid #EFEFEF;
	}

	.unread-text {
		color: #618DFF;
	}
</style>
